package com.zhumo.sz.mapper;

import com.zhumo.sz.entity.bus.BusLineInfo;
import com.zhumo.sz.entity.bus.LengthBusStationInfo;
import com.zhumo.sz.entity.user.UserInfo;
import com.zhumo.sz.provider.BatchInsertProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.mapstruct.Mapper;

import java.util.List;

@Mapper
public interface UserMapper {

    /**
     * 查询所有用户信息
     * @return
     */
    @Select("select * from user_info")
    List<UserInfo> selectAllUser();


    @InsertProvider(type = BatchInsertProvider.class,method = "batchInsert")
    int addUser(@Param("list") List<UserInfo> userInfoList);

    @Update("TRUNCATE table user_info")
    int clearUser();


    /**
     * 用户抽样
     * @param num
     */
    @Select("select * from user_info order by rand() desc limit #{num};")
    List<UserInfo> sampleUser(@Param("num") int num);


    @Select("select * from sz_traffic.length_bus_station_info")
    List<LengthBusStationInfo> getAllLengthBusStation();
}
